<template>
	<view class="content">
		<image src="https://wechat-pictures-1301970825.file.myqcloud.com/shop/note/fasongchenggon.png"></image>
		<view class="msg">点击按钮选择要分享的群或个人！</view>
		<button open-type="share" class="button">继续分享</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: "",
				imageUrl: "",
				path: "",
				q: {}
			}
		},
		onLoad(e) {
			this.title = e.title
			this.imageUrl = e.imageUrl
			this.path = e.path
			if (e.q) {
				this.q = JSON.parse(e.q) || {}
				this.path = this.path + '?' + this.objectToUrlParams(this.q)
			}
		},
		onShareAppMessage(res) {
			return {
				title: this.title,
				path: this.path,
				imageUrl: this.imageUrl
			}
		},
		methods: {
			objectToUrlParams(obj) {
				let params = [];
				for (let key in obj) {
					if (obj.hasOwnProperty(key)) {
						params.push(encodeURIComponent(key) + '=' + encodeURIComponent(obj[key]));
					}
				}
				return params.join('&');
			}
		}
	}
</script>

<style>
	.content {
		width: 100%;
		height: 100vh;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}

	.button {
		width: 90%;
		background-color: #1890FF;
		color: #fff;
		margin-top: 20upx;
		border: none;
		border-radius: 8upx;
	}
</style>